VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "msdatgrd.ocx"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmToolDownloading 
   BorderStyle     =   0  'None
   Caption         =   "Downloading"
   ClientHeight    =   8730
   ClientLeft      =   0
   ClientTop       =   -45
   ClientWidth     =   6825
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   8730
   ScaleWidth      =   6825
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame3 
      Caption         =   " File Path "
      Height          =   4440
      Left            =   3000
      TabIndex        =   8
      Top             =   180
      Width           =   3615
      Begin VB.DirListBox Dir1 
         Appearance      =   0  'Flat
         Height          =   3015
         Left            =   210
         TabIndex        =   10
         Top             =   840
         Width           =   3195
      End
      Begin VB.DriveListBox Drive1 
         Appearance      =   0  'Flat
         Height          =   315
         Left            =   210
         TabIndex        =   9
         Top             =   420
         Width           =   3195
      End
      Begin ITGControls.ITGTextBox txtFilePath 
         Height          =   285
         Left            =   210
         TabIndex        =   11
         Top             =   3990
         Width           =   3195
         _ExtentX        =   5530
         _ExtentY        =   503
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   ""
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   0
         TextBoxWidth    =   3135
         Enabled         =   0   'False
      End
   End
   Begin VB.Frame Frame1 
      Height          =   5565
      Left            =   60
      TabIndex        =   1
      Top             =   -45
      Width           =   6735
      Begin VB.CommandButton cmdPreview 
         Caption         =   "&Preview"
         Height          =   345
         Left            =   4755
         TabIndex        =   15
         Top             =   5070
         Width           =   1800
      End
      Begin VB.CommandButton cmdDLMaint 
         Caption         =   "Download &Maintenance"
         Height          =   345
         Left            =   2910
         TabIndex        =   14
         Top             =   5070
         Width           =   1800
      End
      Begin VB.CommandButton cmdOK 
         Caption         =   "&Download"
         Height          =   345
         Left            =   2910
         TabIndex        =   7
         Top             =   4680
         Width           =   3645
      End
      Begin VB.Frame Frame2 
         Height          =   5310
         Left            =   180
         TabIndex        =   2
         Top             =   180
         Width           =   2565
         Begin VB.CommandButton cmbAllSelected 
            Caption         =   "Check All"
            Height          =   345
            Left            =   120
            TabIndex        =   13
            Top             =   4890
            Width           =   2295
         End
         Begin MSComCtl2.DTPicker DTPicker1 
            Height          =   315
            Left            =   1050
            TabIndex        =   3
            Top             =   300
            Width           =   1215
            _ExtentX        =   2143
            _ExtentY        =   556
            _Version        =   393216
            CustomFormat    =   "MM/dd/yyyy"
            Format          =   88932355
            CurrentDate     =   37393
         End
         Begin MSComCtl2.DTPicker DTPicker2 
            Height          =   315
            Left            =   1050
            TabIndex        =   4
            Top             =   750
            Width           =   1215
            _ExtentX        =   2143
            _ExtentY        =   556
            _Version        =   393216
            CustomFormat    =   "MM/dd/yyyy"
            Format          =   88932355
            CurrentDate     =   37393
         End
         Begin MSComctlLib.ListView lvwTransactions 
            Height          =   3525
            Left            =   120
            TabIndex        =   12
            Top             =   1320
            Width           =   2310
            _ExtentX        =   4075
            _ExtentY        =   6218
            View            =   3
            LabelWrap       =   -1  'True
            HideSelection   =   -1  'True
            AllowReorder    =   -1  'True
            Checkboxes      =   -1  'True
            FullRowSelect   =   -1  'True
            HotTracking     =   -1  'True
            HoverSelection  =   -1  'True
            _Version        =   393217
            ForeColor       =   -2147483640
            BackColor       =   -2147483643
            BorderStyle     =   1
            Appearance      =   0
            NumItems        =   0
         End
         Begin VB.Label Label1 
            Caption         =   "From :"
            Height          =   315
            Left            =   225
            TabIndex        =   6
            Top             =   300
            Width           =   615
         End
         Begin VB.Label Label2 
            Caption         =   "To :"
            Height          =   315
            Left            =   225
            TabIndex        =   5
            Top             =   750
            Width           =   690
         End
      End
   End
   Begin MSComctlLib.StatusBar sbRS 
      Align           =   2  'Align Bottom
      Height          =   300
      Left            =   0
      TabIndex        =   0
      Top             =   8430
      Width           =   6825
      _ExtentX        =   12039
      _ExtentY        =   529
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   4
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3969
            MinWidth        =   3969
         EndProperty
         BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3175
            MinWidth        =   3175
         EndProperty
         BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            AutoSize        =   1
            Bevel           =   0
            Object.Width           =   1272
            MinWidth        =   2
         EndProperty
         BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
            Object.Width           =   3528
            MinWidth        =   3528
         EndProperty
      EndProperty
   End
   Begin MSDataGridLib.DataGrid dtgPreview 
      Height          =   2805
      Left            =   45
      TabIndex        =   16
      Top             =   5580
      Width           =   6705
      _ExtentX        =   11827
      _ExtentY        =   4948
      _Version        =   393216
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1033
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "frmToolDownloading"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'logicglass inc. 2003.10.20

Option Explicit

Dim cndbf As New ADODB.Connection
Dim strDBF As String
Dim oDownload As clsDownloadTransactions
Dim oDownloadMaintenance As clsDownloadMaintenance
Private itmX As Variant

Public sBit As String

Dim lOK As Boolean

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Private Sub cmdDLMaint_Click()
Dim llOK As Boolean
Dim FSO, FS
Dim lFloppy As Boolean
Dim sVar As String

On Error GoTo ErrHandler

    sFilePath = txtFilePath
    
    MousePointer = vbHourglass

    Set FSO = CreateObject("Scripting.FileSystemObject")
    FS = FSO.DeleteFile("-*.itgm") 'FS = FSO.DeleteFile("-*.dbf")
    
    Set oDownloadMaintenance = New clsDownloadMaintenance
    With oDownloadMaintenance

        Set .oSQLConn = cn
            .lOverwrite = True
        
        llOK = .DownloadMaintenance()

    End With
    
    Set oDownload = Nothing
    
    MousePointer = vbDefault
    MsgBox "Downloading COMPLETE!"
    
    Unload Me
    
ErrHandler:
    If err.Number = 53 Then  'File not found.
        Resume Next
    End If
End Sub

Private Sub cmdOK_Click()
Dim llOK As Boolean
Dim FromDate As Date
Dim ToDate As Date
Dim FSO, FS
Dim lFloppy As Boolean
Dim sVar As String

On Error GoTo ErrHandler

    sFilePath = txtFilePath
    
    MousePointer = vbHourglass

    FromDate = Trim(DTPicker1.Value)
    ToDate = Trim(DTPicker2.Value)
    
    Set FSO = CreateObject("Scripting.FileSystemObject")
    FS = FSO.DeleteFile("-*.itg") 'FS = FSO.DeleteFile("-*.dbf")
    
    Set oDownload = New clsDownloadTransactions
    With oDownload

        Set .oSQLConn = cn
            .lOverwrite = True

        For i = 1 To lvwTransactions.ListItems.Count
            If lvwTransactions.ListItems(i).Checked = True Then
            
                If Trim(lvwTransactions.ListItems(i).Text) = "Delivery Receipt" Then
                    llOK = .DownloadDR(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "Sales" Then
                    llOK = .DownloadSales(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "AR Adjustment" Then
                    llOK = .DownloadARAdj(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "Credit Memo per Product" Then
                    llOK = .DownloadCMProd(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "Official Receipt" Then
                    llOK = .DownloadCollection(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "Warehouse Receiving Report" Then
                    llOK = .DownloadWRR(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "Production Order" Then
                    llOK = .DownloadPO(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "Inventory Adjustment" Then
                    llOK = .DownloadInvAdj(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "Inventory Transfer" Then
                    llOK = .DownloadInvTransfer(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "EWT" Then
                    llOK = .DownloadEWT(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "EVAT" Then
                    llOK = .DownloadEVAT(FromDate, ToDate)
                ElseIf Trim(lvwTransactions.ListItems(i).Text) = "CM EWTEVAT" Then
                    llOK = .DownloadCMEWTEVAT(FromDate, ToDate)
                End If
            End If
        Next i

    End With
    
    Set oDownload = Nothing
    
    MousePointer = vbDefault
    MsgBox "Downloading COMPLETE!"
    
    cmdPreview_Click
    'Unload Me
    
ErrHandler:
    If err.Number = 53 Then  'File not found.
        Resume Next
    End If
End Sub

Private Sub cmbAllSelected_Click()
    If cmbAllSelected.Caption = "Check All" Then
        cmbAllSelected.Caption = "Uncheck All"
        For i = 1 To lvwTransactions.ListItems.Count
            lvwTransactions.ListItems(i).Checked = True
        Next i
    Else
        cmbAllSelected.Caption = "Check All"
        For i = 1 To lvwTransactions.ListItems.Count
            lvwTransactions.ListItems(i).Checked = False
        Next i
    End If
End Sub

Private Sub cmdPreview_Click()
Dim rss As New ADODB.Recordset
Dim sTran As String

On Error GoTo TheSource
    
    lOK = False
    
    If rss.State = adStateOpen Then rss.Close
    Set rss = Nothing
    
    Set dtgPreview.DataSource = Nothing
    dtgPreview.Refresh
    
    Select Case Trim(lvwTransactions.SelectedItem.Text)
        Case "Delivery Receipt"
            sTran = "DR.itg"
        Case "Sales"
            sTran = "SALES.itg"
        Case "AR Adjustment"
            sTran = "AR.itg"
        Case "Credit Memo per Product"
            sTran = "CM.itg"
        Case "Official Receipt"
            sTran = "PR.itg"
        Case "Warehouse Receiving Report"
            sTran = "WRR.itg"
        Case "Production Order"
            sTran = "PRODUCTION.itg"
        Case "Inventory Adjustment"
            sTran = "INVADJ.itg"
        Case "Inventory Transfer"
            sTran = "TRANSFER.itg"
        Case "EWT"
            sTran = "EWT.itg"
        Case "EVAT"
            sTran = "EVAT.itg"
        Case "CM EWTEVAT"
            sTran = "CM_EWTEVAT.itg"
            
    End Select
    
    rss.Open txtFilePath & sTran, , adOpenStatic, adLockOptimistic
    Set dtgPreview.DataSource = rss
    rss.Filter = "cCompanyID = " & COID
    
    sbRS.Panels(1) = Trim(lvwTransactions.SelectedItem.Text)
    sbRS.Panels(2) = "Total: 0.00"
    sbRS.Panels(4) = "Recordcount: " & Format(rss.RecordCount, "#,##0")
    
    lOK = True
    
TheSource:
    If Not lOK Then MsgBox "File for download not found!", vbCritical, msgTtl

End Sub

Private Sub Dir1_Change()
    If Dir1.Path <> "C:\" Then
        txtFilePath = Dir1.Path & "\"
    Else
        txtFilePath = Dir1.Path
    End If
    txtFilePath = Trim(Replace(txtFilePath, "\\", "\"))
End Sub

Private Sub Drive1_Change()
    Dir1 = Drive1.Drive
End Sub

Private Sub Form_Activate()
    TBBitReload
End Sub

Private Sub Form_Load()
    Set FrmName = Me
    FormSetup
    
     AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'TL02'")
     
    Drive1.Drive = App.Path
    Dir1.Path = App.Path
    
    DTPicker1.Value = Date - 6
    DTPicker2.Value = Date
    
    Set itmX = lvwTransactions.ColumnHeaders.Add(, , "Transactions")
    lvwTransactions.ColumnHeaders(1).Width = "5000"
    Set itmX = lvwTransactions.ListItems.Add(, , "Delivery Receipt")
    Set itmX = lvwTransactions.ListItems.Add(, , "Sales")
    Set itmX = lvwTransactions.ListItems.Add(, , "AR Adjustment")
    Set itmX = lvwTransactions.ListItems.Add(, , "Credit Memo per Product")
    Set itmX = lvwTransactions.ListItems.Add(, , "Official Receipt")
    Set itmX = lvwTransactions.ListItems.Add(, , "Warehouse Receiving Report")
    Set itmX = lvwTransactions.ListItems.Add(, , "Production Order")
    Set itmX = lvwTransactions.ListItems.Add(, , "Inventory Adjustment")
    Set itmX = lvwTransactions.ListItems.Add(, , "Inventory Transfer")
    Set itmX = lvwTransactions.ListItems.Add(, , "EWT")
    Set itmX = lvwTransactions.ListItems.Add(, , "EVAT")
    Set itmX = lvwTransactions.ListItems.Add(, , "CM EWTEVAT")
    TBBitReload
End Sub

Private Sub Form_Unload(Cancel As Integer)
    CloseMenuTab ITGLedgerMain
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    Set FrmName = Me
    BitVisible ITGLedgerMain.tbrMain, True, True
    sBit = "0000000000001000"
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
End Sub
 'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub
